#include <iostream>
#include <format>
#include <print>
#include <asio.hpp>

using namespace std::chrono_literals;

struct OnWaitCompletion
{
    asio::steady_timer& timer_;
    int& count_;

    void operator()(const std::error_code& ec)
    {
        std::cout << std::format("count [{}]", count_++) << std::endl;
        timer_.expires_at(timer_.expiry() + 1s);
        timer_.async_wait(OnWaitCompletion(*this));
    }
};


int main (int argc, char *argv[]) {
    asio::io_context io;
    asio::steady_timer timer(io, 1s);
    int count = 0;

    timer.async_wait(OnWaitCompletion{timer, count});

    io.run();
    return 0;
}
